/**
 * @file   loggerholder-inl.h
 * @Author Alexandre Chassany (alexandre.chassany@gmail.com)
 * @date   February 2011
 * @brief  LoggerHolder template implementation and specialisation
 *
 * Poum-tchak is a free sound manipulation and synthesis, 
 * real-time and interactive music-clip rendering.
 *
 * Copyright (C) 2011  Chassany Alexandre and Gonzalez Antoine.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * he Free Software Foundation, either version 3 of the License, or
 * at your option) any later version.
 *
 * is program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef _ELIXIR_LOGGERHOLDER_INL_H_
#define _ELIXIR_LOGGERHOLDER_INL_H_

template <class H, class T>
LoggerList<TypeList<H,T> >::LoggerList()
{
  push_back( new Head_t );
  LoggerList<Tail_t> tmp;
  merge( tmp );
}

template <class H, class T>
LoggerList<TypeList<H,T> >::~LoggerList()
{
  LoggerList<List_t>::iterator it;
  for ( it=begin(); it!=end(); ++it )
	delete *it;
}

template<class T>
LoggerHolder<T>::LoggerHolder(){}

template<class T>
LoggerHolder<T>::~LoggerHolder(){}

template<class T> template<class U>
LoggerHolder<T>& LoggerHolder<T>::operator<<( const U& message )
{   
  std::ostringstream oss;
  oss << message;
  for(typename LoggerList<T>::iterator it=loggers_.begin();
	  it!=loggers_.end();++it)
  {
	(**it).write( oss.str() );
  }
  
  return *this;
}

#endif // _ELIXIR_LOGGERHOLDER_INL_H_
